package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "分类相关接口")
@RequestMapping("/user/category")
@RestController("userCategoryController")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 根据类型查询分类
     * @param type 类型（1 菜品分类 2 套餐分类）
     * @return 分类列表
     */
    @ApiOperation(value = "根据类型查询分类")
    @ApiImplicitParam(name = "type", value = "类型（1 菜品分类 2 套餐分类）", paramType = "query", dataType = "int")
    @GetMapping("/list")
    public Result<List<Category>> getCategoryList(Integer type) {
        List<Category> categoryList = categoryService.getCategoryList(type);
        return Result.success(categoryList);
    }
}
